package com.rchat.pocmini.activity.view.location;


import android.content.Context;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * 抽象公告adapter
 *
 * @author mac
 *
 * @param <T>
 */
public abstract class CommonBaseAdapter<T> extends BaseAdapter {

    protected Context mContext;
    protected List<T> mList;
    protected T[] mArray;

    public CommonBaseAdapter(Context context, List<T> mDatas) {
        this.mContext = context;
        this.mList = mDatas;
    }

    public CommonBaseAdapter(Context context, T[] mArray) {
        this.mContext = context;
        this.mArray = mArray;
    }

    @Override
    public int getCount() {
        if (mList != null) {
            return mList.size();
        }
        if (mArray != null) {
            return mArray.length;
        }
        return 0;
    }

    @Override
    public T getItem(int position) {
        if (mList != null) {
            return mList.get(position);
        }
        if (mArray != null) {
            return (T) mArray[position];
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}

